package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select count(1) from t_order where MEMBER_ID = #{mid} and ORDERDATE = #{orderDate} and SETMEAL_ID = #{sid}")
    int hasOrderByOrderDateAndSetmealIdAndMemberId(@Param("orderDate") String orderDate, @Param("sid") int sid, @Param("mid") Integer mid);
     //  根据订单号  查询 体检人名称 套餐名称  预约日期  预约类型


     @Select("SELECT  tm.name as member, ts.name as setmeal,tor.ORDERDATE as orderDate , tor.ORDERTYPE as orderType " +
        "FROM  t_member tm,t_setmeal ts ,t_order tor " +
        "WHERE  tm.id = tor.MEMBER_ID and ts.ID = tor.SETMEAL_ID " +
        "and tor.id = #{id}")
    Map findOrderDetailByOrderId(@Param("id") int id);
}
